<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 14:04:56
 * @LastEditors: charles
 * @LastEditTime: 2021-08-01 14:08:37
-->
<template>
  <div class="details">
    <!-- 快速定位底部顶部 -->
    <div class="toUpBottom">
      <el-button @click="toGo()" type="success" icon="el-icon-arrow-left" circle></el-button>
    </div>

    <div class="wrapper">
      <!-- 标题 -->
      <div class="title">{{ data.name }}</div>
      <!-- 时间地点 -->
      <div class="timePlace">
        <span>
          {{ fmtDate(data.beginTime) }} ~ {{ fmtDate(data.endTime) }}</span
        >

        <span> | {{ data.region }}</span>
      </div>
      <!-- html内容 -->
      <div class="content" v-html="data.details"></div>

      <!-- 报名按钮 -->
      <div class="btn">
        <el-button
          @click="toApply(data.id)"
          type="primary"
          plain
          icon="el-icon-s-order"
          >我要报名</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { fmtDate } from "../filters/index";
import { get } from "../utils/request";
export default {
  data() {
    return {
      id: "",
      data: {},
    };
  },
  methods: {
    fmtDate,
    // 返回上一页
    toGo(){
      this.$router.go(-1)
    },
    // 点击报名按钮方法
    toApply(id) {
      this.$router.push({ path: "./apply", query: { id: id } });
    },
    // 查询项目的详情
    findProjectDetails() {
      // 数据交互
      get("/index/project/findById?id=" + this.id).then((res) => {
        if (res.status == 200) {
          this.data = res.data;
        } else {
          this.$message({
            type: "error",
            message: res.message,
          });
        }
      });
    },
  },
  created() {
    // // 拿到从Home页面传过来的id
    this.id = this.$route.query.id;

    this.findProjectDetails();
  },
};
</script>

<style lang="scss" scoped>
.details {
  padding: 1em 0;
  position: relative;
  .toUpBottom {
    position: fixed;
    top: 100px;
  }
  .wrapper {
    width: 1240px;
    .title {
      font-size: 20px;
      line-height: 3em;
      text-align: center;
      color: #333;
      font-weight: 700;
    }
    .timePlace {
      text-align: center;
      line-height: 2em;
    }
    .content {
      width: 85%;
      margin: 0 auto;
    }
    .btn {
      text-align: center;
    }
  }
}
</style>